﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Bary</title>
<link rel="stylesheet" type="text/css" id="css" href="Resource/css/main.css">


<link rel="stylesheet" type="text/css" href="Resource/yui/build/fonts/fonts-min.css" />
<link rel="stylesheet" type="text/css" href="Resource/yui/build/datatable/assets/skins/sam/datatable.css" />
<script type="text/javascript" src="Resource/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
<script type="text/javascript" src="Resource/yui/build/connection/connection.js"></script>
<script type="text/javascript" src="Resource/yui/build/json/json-min.js"></script>
<script type="text/javascript" src="Resource/yui/build/element/element.js"></script>
<script type="text/javascript" src="Resource/yui/build/paginator/paginator.js"></script>
<script type="text/javascript" src="Resource/yui/build/datasource/datasource.js"></script>
<script type="text/javascript" src="Resource/yui/build/datatable/datatable.js"></script>
<script type="text/javascript" src="Resource/yui/build/utilities/utilities.js"></script>


<body id="yahoo-com" class=" yui-skin-sam">
	<div id="framed">
  	<h2>商品管理</h2>
  </div>
  
  <div>

<!--BEGIN SOURCE CODE FOR EXAMPLE =============================== -->

<div id="demo">
    <div id="paging"></div>
    <div id="dt"></div>
    <br />
    <div id="function"><input type="button" value="管理版色信息" onclick="onSelectRow()" /> &nbsp;<input type="button" value="添加搭配商品" onclick="addPro()" /> &nbsp;<input type="button" value="添加推荐商品" onclick="addLike()" /> &nbsp;&nbsp;<input type="button" value="删除商品" onclick="delGood()" /> &nbsp;</div>
</div>


<script type="text/javascript">
var myDataTable = null;
YAHOO.util.Event.onDOMReady(function () {
    	var DataSource = YAHOO.util.DataSource,
        DataTable  = YAHOO.widget.DataTable,
        Paginator  = YAHOO.widget.Paginator;
        

        var myDataSource = new DataSource("listGoodInit.do?");
        myDataSource.responseType = DataSource.TYPE_JSON;
        myDataSource.responseSchema = {
        		resultsList :"returnObj",  
            fields: ["good_id","good_name","good_feature","good_intro","good_size","like_id","fix_id","current_price","ori_price","cata_id"],
            metaFields: {totalRecords: "totalRecords" }     
        };


		    var buildQueryString = function (state,dt) {
		        return "startIndex=" + state.pagination.recordOffset +
		               "&results=" + state.pagination.rowsPerPage;
		    };
			//alert(myDataSource);

		    var myPaginator = new Paginator({
		        containers         : ['paging'],
		        pageLinks          : 5,
		        rowsPerPage        : 15,
		        rowsPerPageOptions : [15,30,60],
		        template           : "<strong>{CurrentPageReport}</strong> {PreviousPageLink} {PageLinks} {NextPageLink} {RowsPerPageDropdown}",
		        firstPageLinkLabel:"首页",
            lastPageLinkLabel:"末页",
            nextPageLinkLabel:"下一页",
            previousPageLinkLabel:"上一页"

		    });
		
		    var myTableConfig = {
		        initialRequest         : 'startIndex=0&results=25',
		        generateRequest        : buildQueryString,
		        paginationEventHandler : DataTable.handleDataSourcePagination,
		        paginator              : myPaginator
		    };
		  
		    var myColumnDefs = [
            {key:"good_id",label:"商品编号"},
            {key:"good_name",label:"商品名称"},
            {key:"good_feature",label:"商品特性"},
            {key:"good_intro",label:"商品简介"},
            {key:"good_size",label:"商品尺码表"},
            {key:"fix_id",label:"搭配商品"},
            {key:"like_id",label:"可能喜欢商品"},
            {key:"current_price",label:"现价"},
            {key:"ori_price",label:"原价"},
            {key:"cata_id",label:"商品分类"}
        ];
	
        myDataTable = new DataTable("dt", myColumnDefs, myDataSource, myTableConfig);
				myDataTable.subscribe("rowMouseoverEvent", myDataTable.onEventHighlightRow);   
	      myDataTable.subscribe("rowMouseoutEvent", myDataTable.onEventUnhighlightRow);   
	      myDataTable.subscribe("rowClickEvent", myDataTable.onEventSelectRow);   
            
		
       
});

function onSelectRow(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					//alert(record.getData("good_id"));
					location.href = "manageSubColor.do?good_id="+record.getData("good_id");
}

function addLike(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					//alert(record.getData("good_id"));
					location.href = "addLike.do?good_id="+record.getData("good_id");
}

function delGood(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					//alert(record.getData("good_id"));
					location.href = "delGood.do?inputGoodId="+record.getData("good_id");
}

function addPro(){
					var rows =  myDataTable.getSelectedRows();
					var record = myDataTable.getRecord(rows[0]);
					//alert(record.getData("good_id"));
					location.href = "addPro.do?good_id="+record.getData("good_id");
}
</script>

<!--END SOURCE CODE FOR EXAMPLE =============================== -->

  </div>
</body>
</html>